<template>
  <uni-drawer v-if="isDrawer" :mode="mode" ref="filter"><filter-content /></uni-drawer>
  <uni-popup v-else :type="mode" ref="filter"><filter-content /></uni-popup>
</template>

<script>
  import { mainColor } from '@/config/index.js'
  import FilterContent from './filter.vue';
	export default {
		components:{
      FilterContent
		},
		props: {
			filters: {  // 筛选对象
				type: Array,
				default() {
					return [];
				}
			},
			mode: {  // 弹出位置（支持left|right）
				type: String,
				default: 'right'
			},
			bgColor: {  // 选中时的背景颜色
				type: String,
				default: '#fee5e2'
			},
			color: {  // 选中时的字体
				type: String,
				default: mainColor
			},
			resutAll: {  // 重置时是否重置全部（不留默认值，但会保留必填值）
				type: Boolean,
				default: false
			},
			showStatus: {  // 是否顶部留状态栏高度 
				type: Boolean,
				default: false
			},
			showShaixuan: {  // 是否显示筛选
				type: Boolean,
				default: false
			}
		},
    provide() {
      return {
        filters: this.filters, 
        bgColor: this.bgColor, 
        color: this.color, 
        resultAll: this.resultAll, 
        showStatus: this.showStatus, 
        showShaixuan: this.showShaixuan, 
        isDrawer: this.isDrawer
      }
    },
    computed: {
      isDrawer() {
        return ['left', 'right'].indexOf(this.mode) > -1;
      }
    },
		
		methods:{
			close() {
				this.$refs.filter.close();
			},
			open(item) {
				this.$refs.filter.open(); 
			}
		}
	}
</script>
